package qmsz.api.service.impl;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import qmsz.api.dao.QMUserDAO;
import qmsz.api.service.QMUserService;

@Service
public class QMUserServiceImpl implements QMUserService {
	
	private static final Logger logger = Logger.getLogger(QMUserServiceImpl.class);

	@Autowired
	private QMUserDAO qmuserDAO;
	
	@Override
	public int insertUserByMobile(long mobile) {
		int value = 0;
		String randomKey = RandomStringUtils.randomAlphanumeric(32);
		try {
			value = qmuserDAO.insertUserByMobile(randomKey, String.valueOf(mobile));
		} catch (Exception e) {
			logger.error("insert error", e);
			value = 0;
		}
		return value;
	}
	
	@Override
	public String getUserIDByAccount(String account) {
		String id = null;
		try {
			id = qmuserDAO.getUserIDByAccount(account);
		} catch (Exception e) {
			logger.error("query error", e);
			id = null;
		}
		return id;
	}
}
